<template>
    <div class="mod-log">
        <avue-crud :data="dataList"
                   :option="tableOption"
                   :page="page"
                   @on-load="getDataList"
                   @search-change="searchChange"
                   ref="crud">
        </avue-crud>
    </div>
</template>

<script>
    import {tableOption} from '@/crud/sys/log'

    export default {
        data() {
            return {
                dataList: [],
                dataListLoading: false,
                selectionDataList: [],
                tableOption: tableOption,
                page: {
                    total: 0, // 总页数
                    currentPage: 1, // 当前页数
                    pageSize: 10 // 每页显示多少条
                }
            }
        },
        created() {
            this.getDataList()
        },
        methods: {
            // 获取数据列表
            getDataList(page, params, done) {
                this.dataListLoading = true
                this.$http({
                    url: this.$http.adornUrl('/sys/log/page'),
                    method: 'get',
                    params: this.$http.adornParams(
                        Object.assign(
                            {
                                current: page == null ? this.page.currentPage : page.currentPage,
                                size: page == null ? this.page.pageSize : page.pageSize
                            },
                            params
                        )
                    )
                }).then(({data}) => {
                    this.dataList = data.records
                    this.page.total = data.total
                    this.dataListLoading = false
                    if (done) {
                        done()
                    }
                })
            },
            // 条件查询
            searchChange(params, done) {
                this.getDataList(this.page, params, done)
            }
        }
    }
</script>
